package com.jmpt.fangbohui.ui.holder;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jmpt.fangbohui.R;
import com.jmpt.fangbohui.bean.BrokersListBean.Date_row_houseEntity;
import com.jmpt.fangbohui.ui.base.BaseViewHolder;
import com.jmpt.fangbohui.utils.ImageLoaderHelper;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 经纪人列表  条目 holder
 * @author Victor
 *
 */
public class BrokerItemHolder extends BaseViewHolder<Date_row_houseEntity> {

	@ViewInject(R.id.tv_broker_name)
	private TextView mTvName;
	
	@ViewInject(R.id.iv_broker_pic)
	private ImageView mIvPic;
	
	@ViewInject(R.id.tv_broker_tel)
	private TextView mTvTel;
	
	@ViewInject(R.id.tv_broker_com)
	private TextView mTvCom;
	
	@ViewInject(R.id.tv_broker_oldHouse)
	private TextView mTvOldHouse;
	
	@ViewInject(R.id.tv_broker_rentHouse)
	private TextView mTvRentHouse;
	
	public BrokerItemHolder(Context context) {
		super(context);
	}

	@Override
	protected View initView() {
		View view = View.inflate(mContext, R.layout.item_broker, null);
		ViewUtils.inject(this, view);
		return view;
	}

	@Override
	protected void refreshView(Date_row_houseEntity data) {
		if(data == null) return;
		ImageLoaderHelper.displayImage(data.getPicUrl(), mIvPic);
		mTvName.setText(data.getUsername());
		mTvTel.setText("买卖/出租热线：" + data.getPhone());
		mTvCom.setText(data.getZjcname());
		mTvOldHouse.setText( data.getRs_eshouse().equals("0") ? "二手房 (无)" :  "二手房 ("+  data.getRs_eshouse() + "套)");
		mTvRentHouse.setText( data.getRs_renthouse().equals("0") ? "出租房 (无)" :  "出租房 ("+  data.getRs_renthouse() + "套)");
	}

}
